
window.jlpay = new Object();
var jlpaySuccessObject = {};
var id = 0;

var jlpayCallBack = function(res){
    var tempId = res.jlpayId;
    delete res.jlpayId;
    (jlpaySuccessObject[tempId])(res);
    jlpaySuccessObject[tempId]=null;
}

window.jlpay.getLocation = function(object){
    id++;
    try {
        jlpaySuccessObject[id] = object.success;
        window.webkit.messageHandlers.xxxjsGetLocation.postMessage({"type":object.type,"callBack":jlpayCallBack.toString(),"jlpayId":id});
    } catch(e) {
        alert(e.message)
    }
}

window.jlpay.scanQRCode = function(object){
    
    id++;
    try {
        jlpaySuccessObject[id] = object.success;
        window.webkit.messageHandlers.xxxjsScanQRCode.postMessage({"type":object.type,"callBack":jlpayCallBack.toString(),"jlpayId":id});
    } catch(e) {
        alert(e.message)
    }
}

window.jlpay.getAuthInfo = function(object){
    
    id++;
    try {
        jlpaySuccessObject[id] = object.success;
        window.webkit.messageHandlers.xxxjsGetAuthInfo.postMessage({"type":object.type,"callBack":jlpayCallBack.toString(),"jlpayId":id});
    } catch(e) {
        alert(e.message)
    }
    
}

window.jlpay.checkPermisssion = function(object){
    
    id++;
    try {
        jlpaySuccessObject[id] = object.success;
        window.webkit.messageHandlers.xxxjsCheckPermisssion.postMessage({"type":object.type,"callBack":jlpayCallBack.toString(),"jlpayId":id});
    } catch(e) {
        alert(e.message)
    }
    
}


